package com.androidx.p013lv.player.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.bean.VideoBean;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.player.C1387R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import p000a.shuyu.p005a.GSYVideoManager;
import p000a.shuyu.p005a.listener.GSYSampleCallBack;
import p000a.shuyu.p005a.video.StandardGSYVideoPlayer;

/* renamed from: com.androidx.lv.player.view.ListVideoPlayer */
public class ListVideoPlayer extends StandardGSYVideoPlayer {
    private boolean isShow;
    ImageView iv_type;
    ImageView mCoverImage;
    private PlayerVideoInterface playerVideoInterface;
    private int position;
    private LinearLayout root_pay;
    private LinearLayout root_vip;
    private TextView tv_buy_perice;
    private TextView tv_lease_days;
    private TextView tv_lease_perice;
    private VideoBean videoBean;

    /* renamed from: com.androidx.lv.player.view.ListVideoPlayer$PlayerVideoInterface */
    public interface PlayerVideoInterface {
        void buyVideo(ListVideoPlayer listVideoPlayer, VideoBean videoBean, int i);

        void buyVip(ListVideoPlayer listVideoPlayer, VideoBean videoBean, int i);

        void click(ListVideoPlayer listVideoPlayer, VideoBean videoBean, int i);

        void leaseVideo(ListVideoPlayer listVideoPlayer, VideoBean videoBean, int i);
    }

    /* access modifiers changed from: protected */
    @Override // p000a.shuyu.p005a.video.base.GSYVideoControlView
    public void touchDoubleUp() {
    }

    public void setIsBuy(boolean z) {
        this.videoBean.setBuy(z);
        setPay(0);
    }

    public void setVideoBean(VideoBean videoBean2, int i, PlayerVideoInterface playerVideoInterface2) {
        this.videoBean = videoBean2;
        this.position = i;
        this.playerVideoInterface = playerVideoInterface2;
        initVideoData();
    }

    public ListVideoPlayer(Context context, Boolean bool) {
        super(context, bool);
    }

    public ListVideoPlayer(Context context) {
        super(context);
    }

    public ListVideoPlayer(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    /* access modifiers changed from: protected */
    @Override // p000a.shuyu.p005a.video.StandardGSYVideoPlayer, p000a.shuyu.p005a.video.base.GSYVideoControlView, p000a.shuyu.p005a.video.base.GSYBaseVideoPlayer, p000a.shuyu.p005a.video.base.GSYVideoView
    public void init(Context context) {
        super.init(context);
        this.mCoverImage = (ImageView) findViewById(C1387R.C1390id.thumbImage);
        LinearLayout linearLayout = (LinearLayout) findViewById(C1387R.C1390id.root_pay);
        this.root_pay = linearLayout;
        linearLayout.setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.View$OnClickListenerC14141 */

            public void onClick(View view) {
                ARouter.getInstance().build(Constance.VIDEO_PLAY_ACTIVITY).withInt(Key.VIDEO_ID, ListVideoPlayer.this.videoBean.getVideoId()).navigation();
            }
        });
        LinearLayout linearLayout2 = (LinearLayout) findViewById(C1387R.C1390id.root_vip);
        this.root_vip = linearLayout2;
        linearLayout2.setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.View$OnClickListenerC14152 */

            public void onClick(View view) {
                ARouter.getInstance().build(Constance.VIDEO_PLAY_ACTIVITY).withInt(Key.VIDEO_ID, ListVideoPlayer.this.videoBean.getVideoId()).navigation();
            }
        });
        this.iv_type = (ImageView) findViewById(C1387R.C1390id.iv_type);
        this.tv_lease_days = (TextView) findViewById(C1387R.C1390id.tv_lease_days);
        this.tv_lease_perice = (TextView) findViewById(C1387R.C1390id.tv_lease_perice);
        this.tv_buy_perice = (TextView) findViewById(C1387R.C1390id.tv_buy_perice);
        ((TextView) findViewById(C1387R.C1390id.btn_buy_vip)).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.View$OnClickListenerC14163 */

            public void onClick(View view) {
                if (ListVideoPlayer.this.playerVideoInterface != null) {
                    PlayerVideoInterface playerVideoInterface = ListVideoPlayer.this.playerVideoInterface;
                    ListVideoPlayer listVideoPlayer = ListVideoPlayer.this;
                    playerVideoInterface.buyVip(listVideoPlayer, listVideoPlayer.videoBean, ListVideoPlayer.this.position);
                }
            }
        });
        ((LinearLayout) findViewById(C1387R.C1390id.player_btn_lease)).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.View$OnClickListenerC14174 */

            public void onClick(View view) {
                if (ListVideoPlayer.this.playerVideoInterface != null) {
                    PlayerVideoInterface playerVideoInterface = ListVideoPlayer.this.playerVideoInterface;
                    ListVideoPlayer listVideoPlayer = ListVideoPlayer.this;
                    playerVideoInterface.leaseVideo(listVideoPlayer, listVideoPlayer.videoBean, ListVideoPlayer.this.position);
                }
            }
        });
        ((LinearLayout) findViewById(C1387R.C1390id.player_btn_buy)).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.View$OnClickListenerC14185 */

            public void onClick(View view) {
                if (ListVideoPlayer.this.playerVideoInterface != null) {
                    PlayerVideoInterface playerVideoInterface = ListVideoPlayer.this.playerVideoInterface;
                    ListVideoPlayer listVideoPlayer = ListVideoPlayer.this;
                    playerVideoInterface.buyVideo(listVideoPlayer, listVideoPlayer.videoBean, ListVideoPlayer.this.position);
                }
            }
        });
        if (this.mThumbImageViewLayout != null && (this.mCurrentState == -1 || this.mCurrentState == 0 || this.mCurrentState == 7)) {
            this.mThumbImageViewLayout.setVisibility(0);
        }
        setVideoAllCallBack(new GSYSampleCallBack() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.C14196 */

            @Override // p000a.shuyu.p005a.listener.VideoAllCallBack, p000a.shuyu.p005a.listener.GSYSampleCallBack
            public void onPrepared(String str, Object... objArr) {
                super.onPrepared(str, objArr);
                GSYVideoManager.instance().setNeedMute(true);
            }

            @Override // p000a.shuyu.p005a.listener.VideoAllCallBack, p000a.shuyu.p005a.listener.GSYSampleCallBack
            public void onAutoComplete(String str, Object... objArr) {
                super.onAutoComplete(str, objArr);
                ListVideoPlayer.this.mStartButton.setVisibility(8);
                ListVideoPlayer.this.setPay(0);
            }
        });
        findViewById(C1387R.C1390id.view).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.player.view.ListVideoPlayer.View$OnClickListenerC14207 */

            public void onClick(View view) {
                ARouter.getInstance().build(Constance.VIDEO_PLAY_ACTIVITY).withInt(Key.VIDEO_ID, ListVideoPlayer.this.videoBean.getVideoId()).navigation();
            }
        });
    }

    /* access modifiers changed from: protected */
    @Override // p000a.shuyu.p005a.video.StandardGSYVideoPlayer
    public void updateStartImage() {
        if (this.mStartButton instanceof ImageView) {
            ImageView imageView = (ImageView) this.mStartButton;
            if (this.mCurrentState == 2) {
                imageView.setImageResource(0);
            } else if (this.mCurrentState == 0) {
                imageView.setImageResource(C1387R.C1389drawable.player_ic_video_play);
                this.iv_type.setVisibility(0);
            } else {
                imageView.setImageResource(C1387R.C1389drawable.player_ic_video_play);
                this.iv_type.setVisibility(0);
            }
            this.isShow = false;
            this.root_vip.setVisibility(8);
            this.root_pay.setVisibility(8);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void setPay(int i) {
        if (this.videoBean != null) {
            this.iv_type.setVisibility(0);
            UserInfo userInfo = SpUtils.getInstance().getUserInfo();
            if (this.videoBean.getVideoType() == 1 && userInfo.getFreeWatches() != -1) {
                this.root_vip.setVisibility(0);
                this.isShow = true;
            } else if (this.videoBean.getVideoType() != 2 || this.videoBean.isBuy()) {
                this.isShow = false;
                this.root_vip.setVisibility(8);
                this.root_pay.setVisibility(8);
                if (i == 0) {
                    startPrepare();
                    this.iv_type.setVisibility(8);
                }
            } else {
                this.root_pay.setVisibility(0);
                this.isShow = true;
            }
        }
    }

    public void loadCoverImage(String str) {
        RequestManager with = Glide.with(getContext().getApplicationContext());
        ((RequestBuilder) ((RequestBuilder) ((RequestBuilder) with.load(str + "?m=2&w=" + 720 + "&h=" + 405).centerCrop()).error(C1387R.C1389drawable.base_ic_default_cover)).placeholder(C1387R.C1389drawable.base_ic_default_cover)).into(this.mCoverImage);
    }

    private void initVideoData() {
        if (this.videoBean != null) {
            TextView textView = this.tv_lease_days;
            textView.setText(this.videoBean.getLeaseDays() + "");
            TextView textView2 = this.tv_lease_perice;
            textView2.setText(this.videoBean.getLeasePrice() + "");
            TextView textView3 = this.tv_buy_perice;
            textView3.setText(this.videoBean.getPrice() + "");
            if (this.videoBean.getCoverImg() == null || this.videoBean.getCoverImg().size() <= 0) {
                loadCoverImage(SpUtils.getInstance().getString("domain"));
            } else {
                loadCoverImage(SpUtils.getInstance().getString("domain") + this.videoBean.getCoverImg().get(0));
            }
            setUp(UrlManager.getInsatance().playBasePreview() + this.videoBean.getPreviewUrl(), false, "");
            this.iv_type.setVisibility(0);
            if (this.videoBean.getVideoType() == 1) {
                this.iv_type.setImageResource(C1387R.C1389drawable.ic_vip1);
            } else if (this.videoBean.getVideoType() == 2) {
                this.iv_type.setImageResource(C1387R.C1389drawable.ic_pay);
            } else {
                this.iv_type.setImageDrawable(null);
            }
            this.isShow = false;
            this.root_vip.setVisibility(8);
            this.root_pay.setVisibility(8);
        }
    }

    /* access modifiers changed from: protected */
    @Override // p000a.shuyu.p005a.video.StandardGSYVideoPlayer, p000a.shuyu.p005a.video.base.GSYVideoControlView
    public void changeUiToPreparingShow() {
        super.changeUiToPreparingShow();
        setViewShowState(this.mThumbImageViewLayout, 0);
    }

    public void onViewRecycled() {
        this.isShow = false;
        this.root_vip.setVisibility(8);
        this.root_pay.setVisibility(8);
    }

    @Override // p000a.shuyu.p005a.video.base.GSYVideoView
    public void release() {
        super.release();
        Glide.with(this.mCoverImage.getContext()).clear(this.mCoverImage);
    }

    @Override // p000a.shuyu.p005a.video.StandardGSYVideoPlayer, p000a.shuyu.p005a.video.base.GSYVideoView
    public void startPlayLogic() {
        if (this.isShow) {
            GSYVideoManager.onPause();
        } else if (!TextUtils.isEmpty(this.videoBean.getPreviewUrl())) {
            super.startPlayLogic();
            this.root_vip.setVisibility(8);
            this.root_pay.setVisibility(8);
            this.iv_type.setVisibility(8);
        } else {
            GSYVideoManager.onPause();
            setPay(1);
        }
    }

    /* access modifiers changed from: protected */
    @Override // p000a.shuyu.p005a.video.base.GSYVideoControlView
    public void touchSurfaceMoveFullLogic(float f, float f2) {
        super.touchSurfaceMoveFullLogic(f, f2);
        this.mChangePosition = false;
        this.mChangeVolume = false;
        this.mBrightness = false;
    }

    @Override // p000a.shuyu.p005a.video.StandardGSYVideoPlayer, p000a.shuyu.p005a.video.base.GSYVideoView
    public int getLayoutId() {
        return C1387R.C1392layout.video_player_empty_layout;
    }
}
